﻿<%@ page pageEncoding="utf-8"%>
<%@page import="org.json.JSONObject"%>
<%@page import="org.jfaster.db.Configs"%>
<%@page import="java.util.Calendar"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="java.util.Date"%>
<%@page import="com.itsm.v17.entity.WorkOrderOpinion"%>
<%@page import="java.util.List"%>
<%@page import="com.kflow.workflow.po.RecFlow"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
RecFlow flow=(RecFlow)request.getAttribute("flow");
List list=(List)request.getAttribute("opinion");
String orderId=flow.getSerialNO();
String id="";
String context="";
int grade=4;
int serviceGrade=4;
String display="";
String readonly="";
String dataReadyOnly="";
//System.out.println("opinion.size="+list.size());
if(list.size()>0)
{
	WorkOrderOpinion opinion=(WorkOrderOpinion)list.get(0);
	//System.out.println("opinion="+JSONObject.wrap(opinion));
	//System.out.println("opinion="+opinion.getGrade()+","+opinion.getServiceGrade());
	grade=opinion.getGrade();
	serviceGrade=opinion.getServiceGrade();
	//System.out.println("opinion="+grade+","+serviceGrade);
	context=opinion.getContent();
	id=opinion.getId();
	display="none";
	readonly="readonly='readonly'";
	dataReadyOnly="data-readonly";
}

Date completeDate= flow.getCompletedate();
String completeDateString="";
String endDateString="";

%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
  <head>
    <title>工单评价</title>
    <script src="<%=basePath%>itsm-wechat/js/jquery.min.js"></script>
    <link href="<%=basePath%>itsm-wechat/css/font-awesome/css/font-awesome.min.css" rel="stylesheet">
    <link href="<%=basePath%>itsm-wechat/css/bootstrap/css/bootstrap.min.css" rel="stylesheet">
    <script src="<%=basePath%>itsm-wechat/css/bootstrap/js/bootstrap.min.js"></script>
    <!-- <script src="src/bootstrap-rating-input.js"></script> -->
    <script src="<%=basePath%>itsm-wechat/js/bootstrap-rating-input.min.js"></script>
    <script>
      $(function(){
        $('input').on('change', function(){
          //alert("Changed: " + $(this).val())
        });
      });
    </script>
    <title>工单评价</title>
<script src="<%=basePath%>itsm/js/ajax.js"></script>
<script src="<%=basePath%>itsm/js/formValidate.js"></script>
<style>
body{
	font-size:24px;
}
.show{
display:<%=display%>;
}
.small{
font-size: 150%;
line-height: 200%;
margin-top:15px;
}
.button{
background: blue none repeat scroll 0 0;
    color: white;
    display: block;
    padding: 15px;
    text-decoration: none;
    margin-top:15px;
	width:200px;
	height:72px !important;
	font-size:150%;
}
td>b {
  font-size:160%;
  }
  
  .rating-input>i {
	font-size:350%;
  margin-left:10px;
margin-right:20px;
color:red
  }
tr {
	height:80px
}
</style>
  </head>
  <body>
  
  
  	<table width="100%" id="dataTable" >
		<tr><td><b><%=flow.getTitle()%></b></td></tr>
		<tr class="small" style="display:none;" ><td>
			工单完成时间:<%=completeDateString %>
			<br/>
			评价截止时间:<%=endDateString %>
		</td></tr>
		<tr class="small"><td>工程师评价1</td></tr>
		<tr><td>
			<%--
			<input type="hidden" id="grade" value="<%=grade%>" />
			<iframe src="<%=basePath%>itsm/plugins/opinion/index.jsp?type=grade&grade=<%=grade%>"  width="100%" 
			height="30px" frameborder="0" scrolling="no" ></iframe>
			 --%>
			<%-- <input type="number" name="grade" id="grade" <%=dataReadyOnly%> class="rating"  value="<%=grade%>" /> --%>
		</td></tr>
		<tr class="small"><td>服务台评价</td></tr>
		<tr><td>
		<%--
			<input type="hidden" id="serviceGrade" value="<%=serviceGrade%>" />
			<iframe src="<%=basePath%>itsm/plugins/opinion/index.jsp?type=serviceGrade&grade=<%=serviceGrade%>"  width="100%" 
			height="30px" frameborder="0" scrolling="no" ></iframe>
			 --%>
		<%-- 	<input type="number" name="serviceGrade" <%=dataReadyOnly%> id="serviceGrade" class="rating"  value="<%=serviceGrade%>" /> --%>
			
		</td></tr>
		<tr class="small"><td>评价内容</td></tr>
		<tr><td>
		<textarea class="small" width="100%" <%=readonly%> rows="3" id="content" require=true max=200 
		message="评价内容最多200个字符" style="width:100%;"><%=context%></textarea>
		</td></tr>
		
		<tr class="show"><td align="center">
		<a class="button" href="javascript:;" onclick="submitOpinion()" style="display:<%=display%>;" id="buttonA" >提 交 </a></td></tr>
		<tr class="small"><td align="center"><span id="message"></span></td></tr>
	</table>
<script>
var orderId="<%=orderId%>";
function starCall(type,grade)
{
	//orderId=type;
	//grade=gradeTemp;
	get(type).value=grade;
}
function submitOpinion()
{
	get("message").innerHTML='';
	var flag=formValidate("dataTable");
	if(!flag){return;}
	get("message").innerHTML="正在提交...";
	var args="id=<%=id%>";
	args=args+"&workOrderId="+orderId;
	args=args+"&grade="+get("grade").value;
	args=args+"&serviceGrade="+get("serviceGrade").value;
	args=args+"&content="+encodeURI(encodeURI(get("content").value));
	new ajax({"url":"<%=basePath%>itsm17/workorder/opinion/save","params":args,"success":function(data)
		{
		get("message").innerHTML='';
			var json=toJson(data);
			if(json.result)
			{
				get("message").innerHTML='<font color=green>提交成功</font>';	
				get("buttonA").style.display="none";
				get("content").readOnly=true;
				$("#grade").attr("data-readonly","");
				$("#serviceGrade").attr("data-readonly","");
			}else
			{
				get("message").innerHTML='<font color=red>'+json.message+'</font>';	
			}
		}});
	
}
</script>

  </body>
</html>
